//
//  AXMyHyzxVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/19.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyHyzxVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "Header.h"
#import "UITableView+SDAutoTableViewCellHeight.h"
#import "AXMyHyzxTableViewCell.h"
#import "AXMyHyzxModel.h"
#import "UIViewController+HBD.h"

@interface AXMyHyzxVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<AXMyHyzxModel *>  *modelsArray;
/** 假数据 */
@property (nonatomic, strong) NSArray<NSString *> *titles;
@property (nonatomic, strong) NSArray<NSString *> *contents;
@property (nonatomic , assign) NSInteger requstIndex;



@end

@implementation AXMyHyzxVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupNavigationItems];
    [self initData];
    [self creatView];
    [self setlayout];
    /** 导航条白色 */
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    
    
    
}

- (void)creatView {
    
    self.tableView = [[UITableView alloc]init];
    /** 去掉cell线 */
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXMyHyzxTableViewCell class] forCellReuseIdentifier:[AXMyHyzxTableViewCell reuseID]];
    [self.view addSubview:self.tableView];
    
    
    
}

- (void)initData {
    
    self.titles = @[@"3.2.1  V1-绿卡会员",@"3.2.2  V2-青卡会员：",@"3.2.3  V3-蓝卡会员：",@"3.2.4  V4-紫卡会员：",@"3.2.5  V5-钻石会员："];
    self.contents = @[@"在“安心100”电商平台新注册成功后，并在平台上完善个人信息实名认证审核通过后，自动成为绿卡会员，按积分获取规则获得相应积分奖励；原则上绿卡会员积分＜5000积分或个人账户名下累计发生交易额＜5000元。",@"个人账户名下累计发生交易额＞5000元或累计积分在5000~9999积分，系统自动升级为青卡会员，按积分获取规则获得相应会员积分政策与奖励；",@"个人账户名下累计发生交易额＞10000元或累计积分在10000~49999积分，系统自动升级为蓝卡会员，按积分获取规则获得相应会员积分政策与奖励；",@"个人账户名下累计发生交易额＞50000元或累计积分在50000~99999积分，系统自动升级为紫卡会员，按积分获取规则获得相应会员积分政策与奖励。",@"个人账户名下累计发生交易额＞100000元累计积分＞100000积分，系统自动升级为钻石会员，按积分获取规则获得相应会员积分政策与奖励。"];
    
    
}

- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, NAVIGATION_HEIGHT)
    .widthIs(Wi)
    .heightIs(TableViewHeight);
    
    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    /** 搜索 */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"会员规则";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_EIGHTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - tableViewDelegate & tableViewDatasorce



//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

/** cell的高度 */

/** cell 自适应第二步 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return [tableView cellHeightForIndexPath:indexPath model:self.modelsArray[indexPath.row] keyPath:@"model" cellClass:[AXMyHyzxTableViewCell class] contentViewWidth:SCREEN_WIDTH];
    
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    AXMyHyzxTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMyHyzxTableViewCell reuseID] forIndexPath:indexPath];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    cell.titleLabel.text = self.titles[indexPath.section];
    cell.contentLabel.text = self.contents[indexPath.section];
    
    if (indexPath.section == 0) {
        cell.titleLabel.textColor = COLOR_GREEN;
    }else if (indexPath.section == 1) {
        cell.titleLabel.textColor = [UIColor colorWithHex: 0x0db3b1];
    }else if (indexPath.section == 2) {
         cell.titleLabel.textColor = [UIColor colorWithHex:0x237bde];
    }else if (indexPath.section == 3) {
         cell.titleLabel.textColor = [UIColor colorWithHex:0xcd21d8];
    }else if (indexPath.section == 4) {
        cell.titleLabel.textColor = [UIColor colorWithHex:0xff9e05];
    }
    
    
    return cell;
    
    
}



@end

